import request from '@/utils/request';

//获取u设备分类汇总
export async function GetDeviceTypeList(params) {
    try {
        const res = await request.get('/api/system/devSensor/getDevTotByDeviceType',  {
            params
        });
        return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
}
export async function EventAlarm(params) {
  try {
      const res = await request.post('/api/alarmInfo/eventAlarm',
          params
      );
      return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}
export async function updateAlarmCallBackInfo(params) {
  try {
      const res = await request.post('/api/alarmInfo/updateAlarmCallBackInfo',
          params
      );
      return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

export async function GetDeviceInfo(deviceId,params) {
    try {
        const res = await request.get(`/api/system/devSensor/getDeviceInfo/${deviceId}`,  {
            params
        });
        return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
}

export async function firstIdentificationCircle(placeId) {
  try {
      const res = await request.get(`/api/preventionLoop/firstIdentificationCircle/${placeId}`, );
      return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

export async function secondIdentificationCircle(placeId) {
  try {
      const res = await request.get(`/api/preventionLoop/secondIdentificationCircle/${placeId}`, );
      return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

export async function thirdIdentificationCircle(placeId) {
  try {
      const res = await request.get(`/api/preventionLoop/thirdIdentificationCircle/${placeId}`, );
      return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

export async function fourthIdentificationCircle(placeId) {
  try {
      const res = await request.get(`/api/preventionLoop/fourthIdentificationCircle/${placeId}`, );
      return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

//根据节点获取该节点对应的经纬度
export async  function getLocationById(params) {
  try {
      const res =await request.get(`/api/system/dept/getLocationById`,  {
          params
      });
      return res.code == 200 ? Promise.resolve(res.data) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

export async  function getDistrictVehicleForPage(params) {
  try {
      const res =await request.get(`/api/preventionLoop/getDistrictVehicleForPage`,  {
          params
      });
      return res.code == 200 ? Promise.resolve(res.data) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

export async function GetDeviceLocationList(params) {
    try {
        const res = await request.get('/api/system/devSensor/getLocation',  {
            params
        });
        return res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
}

//获取单个设备的近24小时整点数据
export async function GetHistoryOneDay(params) {
  try {
    const res = await request.get('/api/dataAnalysis/historydata/getHistoryOneDay', {
      params
    })
    return res.code == 200 ? Promise.resolve(res.data) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}

//获取实时设备
export async function GetRedisDeviceInfo(params) {
  try {
    const res = await request.get('/api/dataAnalysis/historydata/getDeviceInfo', {
      params
    })
    return res.code == 200 ? Promise.resolve(res.data) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}


//获取小区设备类型
export async function getDevByPlaceId(params) {
  try {
    const res = await request.get('/api/system/devSensor/getDevTotByDeviceType', {
      params
    })
    return res.code == 200 ? Promise.resolve(res.data) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}

//获取小区设备类型
export async function getAlarmListForPage(params) {
  try {
    const res = await request.get('/api/alarmInfo/getAlarmListForPage', {
      params
    })
    return res.code == 200 ? Promise.resolve(res.data) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}


export function DevicesTypes(){
  var arr = [
    {
      devtype: "1",
      devname: "窖井盖监测",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出安全阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "1",
      devname: "窖井盖监测",
      alarmcode: "2",
      alarmcodename: "告警数据上行- 超出告警阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "1",
      devname: "窖井盖监测",
      alarmcode: "1",
      alarmcodename: "告警恢复上行- 超出安全阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "1",
      devname: "窖井盖监测",
      alarmcode: "2",
      alarmcodename: "告警恢复上行- 超出告警阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "2",
      devname: "可燃气体报警",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "2",
      devname: "可燃气体报警",
      alarmcode: "1",
      alarmcodename: "告警恢复上行- 超出阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "3",
      devname: "无线烟感",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "3",
      devname: "无线烟感",
      alarmcode: "1",
      alarmcodename: "告警恢复上行- 超出阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "4",
      devname: "Lora基站",
      alarmcode: "",
      alarmcodename: "",
      codetype: "",
      codetypename: "",
      alarmlevel: "",
      alarmlevelname: ""
    },
    {
      devtype: "5",
      devname: "消防栓水压监测",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "5",
      devname: "消防栓水压监测",
      alarmcode: "1",
      alarmcodename: "告警恢复上行- 超出阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "6",
      devname: "水质检测仪",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出温度阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "6",
      devname: "水质监测仪",
      alarmcode: "2",
      alarmcodename: "告警数据上行- 超出TDS阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "6",
      devname: "水质检测仪",
      alarmcode: "3",
      alarmcodename: "告警数据上行- 超出盐度阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "6",
      devname: "水质监测仪",
      alarmcode: "4",
      alarmcodename: "告警数据上行- GSP 掉线",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "6",
      devname: "水质检测仪",
      alarmcode: "5",
      alarmcodename: "告警数据上行- GSP 重启",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "6",
      devname: "水质监测仪",
      alarmcode: "1",
      alarmcodename: "告警恢复上行- 超出温度阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "6",
      devname: "水质检测仪",
      alarmcode: "2",
      alarmcodename: "告警恢复上行- 超出TDS阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "6",
      devname: "水质监测仪",
      alarmcode: "3",
      alarmcodename: "告警恢复上行- 超出盐度阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "6",
      devname: "水质检测仪",
      alarmcode: "4",
      alarmcodename: "告警恢复上行- GSP 掉线",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "6",
      devname: "水质监测仪",
      alarmcode: "5",
      alarmcodename: "告警恢复上行- GSP 重启",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "7",
      devname: "消防水箱液位监测",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出液压阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "7",
      devname: "消防水箱液位监测",
      alarmcode: "2",
      alarmcodename: "告警数据上行- GSP掉线",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "7",
      devname: "消防水箱液位监测",
      alarmcode: "3",
      alarmcodename: "告警数据上行- GSP重启",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "7",
      devname: "消防水箱液位监测",
      alarmcode: "1",
      alarmcodename: "告警恢复上行-  超出液压阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "7",
      devname: "消防水箱液位监测",
      alarmcode: "2",
      alarmcodename: "告警恢复上行- GSP 掉线",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "7",
      devname: "消防水箱液位监测",
      alarmcode: "3",
      alarmcodename: "告警恢复上行- GSP 重启",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "8",
      devname: "水泵房漏水监测",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出液位阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "8",
      devname: "水泵房漏水监测",
      alarmcode: "2",
      alarmcodename: "告警数据上行- GSP掉线",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "8",
      devname: "水泵房漏水监测",
      alarmcode: "3",
      alarmcodename: "告警数据上行- GSP重启",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "8",
      devname: "水泵房漏水监测",
      alarmcode: "1",
      alarmcodename: "告警恢复上行-  超出液位阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "8",
      devname: "水泵房漏水监测",
      alarmcode: "2",
      alarmcodename: "告警恢复上行- GSP 掉线",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "8",
      devname: "水泵房漏水监测",
      alarmcode: "3",
      alarmcodename: "告警恢复上行- GSP 重启",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "9",
      devname: "水浸传感器",
      alarmcode: "1",
      alarmcodename: "告警数据上行- GSP掉线",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "9",
      devname: "水浸传感器",
      alarmcode: "2",
      alarmcodename: "告警数据上行- GSP重启",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "9",
      devname: "水浸传感器",
      alarmcode: "1",
      alarmcodename: "告警恢复上行- GSP 掉线",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "9",
      devname: "水浸传感器",
      alarmcode: "2",
      alarmcodename: "告警恢复上行- GSP 重启",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "1",
      alarmcodename: "上送最大风速告警",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "1",
      alarmcodename: "上送最大风速告警恢复",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "2",
      alarmcodename: "上送雨量告警",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "2",
      alarmcodename: "上送雨量告警恢复",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "3",
      alarmcodename: "紫外线告警",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "3",
      alarmcodename: "紫外线告警恢复",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "4",
      alarmcodename: "pm2.5 告警",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "4",
      alarmcodename: "pm2.5 告警恢复",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "5",
      alarmcodename: "pm10 告警",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "5",
      alarmcodename: "pm10 告警恢复",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "6",
      alarmcodename: "噪音告警",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "6",
      alarmcodename: "噪音告警恢复",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "7",
      alarmcodename: "告警数据上行- GSP掉线",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "7",
      alarmcodename: "告警恢复上行- GSP 掉线",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "8",
      alarmcodename: "告警数据上行- GSP重启",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "10",
      devname: "小型气象站监测",
      alarmcode: "8",
      alarmcodename: "告警恢复上行- GSP 重启",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "11",
      devname: "水表",
      alarmcode: "",
      alarmcodename: "",
      codetype: "",
      codetypename: "",
      alarmlevel: "",
      alarmlevelname: ""
    },
    {
      devtype: "12",
      devname: "电表",
      alarmcode: "1",
      alarmcodename: "上送电表故障告警",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "12",
      devname: "电表",
      alarmcode: "1",
      alarmcodename: "上送电表故障告警恢复数据",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "12",
      devname: "电表",
      alarmcode: "2",
      alarmcodename: "上送自定义告警数据",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "12",
      devname: "电表",
      alarmcode: "2",
      alarmcodename: "上送自定义告警恢复数据",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "13",
      devname: "污水流量监测仪",
      alarmcode: "",
      alarmcodename: "",
      codetype: "",
      codetypename: "",
      alarmlevel: "",
      alarmlevelname: ""
    },
    {
      devtype: "14",
      devname: "污水井液位监测",
      alarmcode: "1",
      alarmcodename: "告警数据上行- 超出液位阈值",
      codetype: "2",
      codetypename: "上限告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "14",
      devname: "污水井液位监测",
      alarmcode: "1",
      alarmcodename: "告警恢复上行-  超出液位阈值",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "14",
      devname: "污水井液位监测",
      alarmcode: "2",
      alarmcodename: "告警数据上行- GSP掉线",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "1",
      alarmlevelname: "级别严重，告警上报处理"
    },
    {
      devtype: "14",
      devname: "污水井液位监测",
      alarmcode: "2",
      alarmcodename: "告警恢复上行- GSP 掉线",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "14",
      devname: "污水井液位监测",
      alarmcode: "3",
      alarmcodename: "告警数据上行- GSP重启",
      codetype: "1",
      codetypename: "设备告警码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    },
    {
      devtype: "14",
      devname: "污水井液位监测",
      alarmcode: "3",
      alarmcodename: "告警恢复上行- GSP 重启",
      codetype: "3",
      codetypename: "告警恢复码",
      alarmlevel: "3",
      alarmlevelname: "级别一般，不处理"
    }
  ]
  return arr

}
